package tools

import (
	"fmt"
	"strconv"
	"strings"
)

// MapToQuery 将map的键值对转化为abc=123&cse=345
func MapToQuery(params map[string]string) (paramStr string) {
	slice := make([]string, len(params))
	for k, v := range params {
		slice = append(slice, fmt.Sprintf("%s=%s", k, v))
	}
	paramStr = strings.Join(slice, "&")
	return
}

func MapToString(params map[string]string) (paramStr string) {
	slice := make([]string, len(params))
	for k, v := range params {
		slice = append(slice, fmt.Sprintf("%s:%s", k, v))
	}
	return
}
func StringToSliceInt32(str string) []int32 {
	sa := strings.Split(str, ",")
	var s []int32
	for _, v := range sa {
		t, _ := strconv.Atoi(v)
		s = append(s, int32(t))
	}
	return s
}
